package week12;

import java.util.*;
public class MySort2 {
    public static void main(String [] args) {
        String [] toSort = {"aaa:10:1:1",
                "ccc:30:3:4",
                "bbb:50:4:5",
                "ddd:20:5:3",
                "eee:40:2:20"};

        System.out.println("Before sort:");
        for (String str: toSort)
            System.out.println(str);

        /*List<String> list = new ArrayList();
        for (String str: toSort)
            list.add(str);
        System.out.println(list.size());*/

        List<String> tmp1 = new ArrayList();
        for(int i = 0; i < toSort.length; i++){
            tmp1.add(toSort[i].split(":")[1]);
        }
        //System.out.println(tmp1);

        Collections.sort(tmp1);

        //System.out.println(tmp1);

        System.out.println("After sort:");

        for(int i = 0; i < tmp1.size(); i++)
            for(int j = 0; j < tmp1.size(); j++){
                if(toSort[j].split(":")[1].equals(tmp1.toArray()[i]) )
                    System.out.println(toSort[j]);
            }
    }
}